function setActivityValue(box) {
	var idx = box.selectedIndex;
	if (idx == 0) {
		$('input#activity').attr('value', "");
	} else {
		$('input#activity').attr('value', idx);
	}
}

function submitForm(actionValue) {
	document.forms[0].action = actionValue;
	document.forms[0].submit();
}

function doPaginate(pageNumber) {
	//alert('doPaginate '+pageNumber );
	if (document.getElementById('pageIndex') != null) {
		//alert('element : pageIndex found');
		var myElement = document.getElementById('pageIndex');
		myElement.value = pageNumber;
		//submitToURL(document.getElementById('type').value);
		document.forms[0].submit();
	}
}

function jumbToPage(event) {
	if (event.keyCode == '13') {
		if ((document.getElementById)
				&& (document.getElementById('pageIndex') != null)) {
			page = document.getElementById('pageIndex').value;
			if (isNaN(parseInt(page)) || parseInt(page) < 1) {
				alert('invalid page number');
			} else {
				doPaginate(page);
			}
		}
	}
}

function doSorting(sortField) {
	if (document.getElementById('sortField') != null
			&& document.getElementById('assending') != null) {
		sortFieldEl = document.getElementById('sortField');
		sortTypeEl = document.getElementById('assending');
		sortFieldElOld = sortFieldEl.value;
		if (sortField != sortFieldElOld) {
			sortFieldEl.value = sortField;
			sortTypeEl.value = 'true';
		} else {
			oldSortType = sortTypeEl.value;
			if (oldSortType == 'true') {
				sortTypeEl.value = 'false';
			} else {
				sortTypeEl.value = 'true';
			}
		}
		document.getElementById('pageIndex').value = 1;
		document.forms[0].submit();
	} else {
		alert('faild to sort');
	}
}
